﻿using GameProtocols;
using Network;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;



public class PlayerControl : MonoBehaviour
{
    int mLastInput;
    // Update is called once per frame
    void Update()
    {
        int input = GetKeyDown();
        if(input != mLastInput)
        {
            PKG_OPERATION operation = new PKG_OPERATION();
            operation.operation = GetKeyDown();
            NetManager.Instance.SendUdpMessage((ushort)ProtoId.MSG_OPERATION, operation);
        }
        mLastInput = input;
    }
    int GetKeyDown()
    {
        int input = 0;
        if (Input.GetKey(KeyCode.A))
            input |= 1 << 0;
        if (Input.GetKey(KeyCode.S))
            input |= 1 << 1;
        if (Input.GetKey(KeyCode.D))
            input |= 1 <<2;
        if (Input.GetKey(KeyCode.W))
            input |= 1 << 3;
        if (Input.GetKey(KeyCode.J))
            input |= 1 << 4;
        if (Input.GetKey(KeyCode.K))
            input |= 1 << 5;

        return input;
    }

   
}
